<template>
  <!-- 环境管理工具 -->
  <el-form
    ref="formRef"
    label-width="80px"
    :model="form"
    class="tools-project-control-form form-2-layout"
  >
    <el-form-item label="项目位置">
      <SelectSaveFilePath v-model="form.filePath" @selectFilePath="selectFilePath"
    /></el-form-item>
    <el-form-item label="选择项目">
      <el-select v-model="form.name" filterable placeholder="请选择项目" :clearable="true">
        <el-option v-for="item in nameList" :key="item" :label="item" :value="item" />
      </el-select>
    </el-form-item>
    <el-form-item label="切换环境" class="form-item-line-1">
      <el-select v-model="form.env" filterable>
        <el-option
          v-for="item in ['dev', 'qa', 'prod', 'customer']"
          :key="item"
          :label="item"
          :value="item"
        />
      </el-select>

      <el-input
        v-if="form.env === 'customer'"
        placeholder="请输入内容"
        v-model="form.customer"
        type="textarea"
        class="tools-project-control-textarea"
        :autosize="{ minRows: 4, maxRows: 8 }"
      ></el-input>
    </el-form-item>
  </el-form>
</template>

<script setup lang="ts">
import { defaultConfig } from '../config'
defineProps<{
  form: any
}>()
// const form = reactive({
//   filePath: defaultConfig.basePath,
//   name: '',
//   env: 'dev',
//   customer: ''
// })
const nameList = ref([])
onMounted(() => {
  getFilsName()
})
const getFilsName = async () => {
  let res = await window.electronAPI.getAllFiles(defaultConfig.basePath)
  nameList.value = res
  return res
}
const selectFilePath = async () => {}
</script>

<style lang="scss" scoped></style>
